package com.fuful.domain;

import java.util.List;

/**
 * Created by Administrator on 2019/7/24.
 */
public class Page<T>{
    private int pageNumber;//当前页

    private int total;//总记录数

    private  int pageSize;//每页记录数

        private int pageCount;//总页数

        private int pre;//上一页

        private int next;//下一页

        private int start;//每页的起始位置

    private List<T> rows;//每页的数据

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public int getTotal() {
        return total;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getPageCount() {
        return (total+pageSize-1)/pageSize;
    }

    public int getPre() {
        if (pageNumber>1)
            return pageNumber-1;
            return 1;//到第一页 再点上一页 永远返回 第一页
    }

    public int getNext() {
        if (pageNumber<getPageCount()){
        return pageNumber+1;}
        return getPageCount();//到最后一页再点下一页 则永远返回最后一页
    }

    public int getStart() {
        return (pageNumber-1)*pageSize;
    }

    public List<T> getRows() {
        return rows;
    }


}
